/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package pfc.arbol;

import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.JSeparator;
import org.apache.commons.lang.StringUtils;
import pfc.comun.IDEpfc;
import pfc.comun.Proyecto;
import pfc.gui.EntityEdit;
import pfc.modeloer.EREntity;

/**
 *
 * @author xandru
 */
public class EntityTreeNode extends PFCTreeNode{

    EREntity _e;

    public EntityTreeNode(Proyecto p, String n, EREntity e)
    {
        super(p,n);
        this._e = e;
        construirMenuContexto();
    }

    public void setEntity(EREntity e)
    {
        this._e = e;
    }

    public EREntity getEntity()
    {
       return _e;
    }


    protected void construirMenuContexto() {
        popupMenu = new JPopupMenu();

        JMenuItem mi = new JMenuItem("Propiedades");
        mi.setActionCommand("showProperties");
        //mi.addActionListener(this);


        mi.addActionListener(new java.awt.event.ActionListener() {
                                public void actionPerformed(java.awt.event.ActionEvent e) {
                                    showProperties();
            }

        });



        popupMenu.add(mi);
        mi.setEnabled(true);
         

        popupMenu.add(new JSeparator());

    }

    @Override
    public void showProperties()
    {
        IDEpfc.logTime("Editando propiedades de la entidad " + _e.getName());
        System.out.println("Propiedades de " + this.getClass().getName());
        EntityEdit eEdit = new EntityEdit(this);
        IDEpfc.app.addParaEditar(eEdit,  StringUtils.capitalize(_e.getName()));
    }
}
